package ru.ipo.dces.trashtests;

import ru.ipo.dces.serverbeans.BeansRegistrator;
import ru.ipo.dces.serverbeans.ContestDescriptionBean;
import ru.ipo.structurededitor.Defaults;
import ru.ipo.structurededitor.StructuredEditor;
import ru.ipo.structurededitor.controller.EditorsRegistry;
import ru.ipo.structurededitor.model.DSLBeansRegistry;
import ru.ipo.structurededitor.view.EditorRenderer;
import ru.ipo.structurededitor.view.StructuredEditorModel;

import javax.swing.*;
import java.awt.*;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: ilya
 * Date: 28.10.2010
 * Time: 1:12:53
 */
public class BeansEditor {

    public static void main(String[] args) {

        /*EditorsRegistry editors = new EditorsRegistry();
        Defaults.registerDefaultEditors(editors);

        DSLBeansRegistry registry = new DSLBeansRegistry();
        BeansRegistrator.register(registry);
        registry.registerBean(ContestDescriptionBean.class);

        ContestDescriptionBean ccrb = new ContestDescriptionBean();
        StructuredEditorModel model = new StructuredEditorModel(ccrb);
        model.setRootElement(new EditorRenderer(model, ccrb).getRenderResult());*/

        JFrame f = new JFrame("Редактирование ContestDescription");
        BorderLayout br = new BorderLayout();
        f.setLayout(br);
        //StructuredEditor structuredEditor = new StructuredEditor(model);
        //JScrollPane structuredEditorScrPane = new JScrollPane(structuredEditor);
        //f.add(structuredEditorScrPane, BorderLayout.CENTER);

        JSpinner timeSpinner = new JSpinner();
        timeSpinner.setModel(new SpinnerDateModel());
        JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "yyyy:MM:dd HH:mm:ss");
        timeSpinner.setEditor(timeEditor);
        timeSpinner.setValue(new Date()); // will only show the current time

        f.add(timeSpinner);

        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(640, 480);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }

}